package dper.study.codes.common.simulation4jvmstudy;

/**
 * Created by leichen on 2017/5/18.
 */
public class JStackResourceSImulation {
    static class LogThread implements Runnable {

        private String name;

        public LogThread(String name) {
            this.name = name;
        }

        public void run() {
            for(int i=0; i< 100; i++){
                try {
                    ResourcePool.getInstance().hello();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("Hello " + name + ". This is " + i);
            }
            System.out.println("Hello " + name + ". End...");
        }
    }

    public static void main(String[] args){

        System.out.println("Start");
        for(int j = 0; j < 10; j++){
            Runnable task = new LogThread("World" + j);
            Thread t = new Thread(task);
            t.start();
        }
        System.out.println("Ok.");
    }
}
